package com.atguigu.schedule.pojo;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 验证码实体类
 * 
 * @author atguigu
 * @since 2024
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class VerificationCode implements Serializable {
    
    private Long id;
    
    private String phone;
    
    private String code;
    
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime expireTime;
    
    private Boolean used = false;
    
    /**
     * 构造函数
     */
    public VerificationCode(String phone, String code) {
        this.phone = phone;
        this.code = code;
        this.createTime = LocalDateTime.now();
        this.expireTime = LocalDateTime.now().plusMinutes(10); // 10分钟过期
    }
}
